<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
 * @OA\Schema(
 *     schema="WorkUserResource",
 *     title="维护人员资源",
 *     description="维护人员信息",
 *     @OA\Property(property="id", type="integer", description="维护人员ID", example=1),
 *     @OA\Property(property="real_name", type="string", description="真实姓名", example="李师傅"),
 *     @OA\Property(property="username", type="string", description="用户名", example="lifu"),
 *     @OA\Property(property="tel", type="string", description="联系电话", example="13800138000"),
 *     @OA\Property(property="enable", type="boolean", description="是否启用", example=true),
 *     @OA\Property(property="memo", type="string", description="备注", example="维护人员备注信息"),
 *     @OA\Property(property="expired_at", type="string", format="date-time", description="过期时间", example="2025-12-31 23:59:59"),
 *     @OA\Property(property="created_at", type="string", format="date-time", description="创建时间", example="2025-01-01 12:00:00"),
 *     @OA\Property(property="updated_at", type="string", format="date-time", description="更新时间", example="2025-01-01 12:00:00")
 * )
 */
class WorkUserResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'real_name' => $this->real_name,
            'username' => $this->username,
            'tel' => $this->tel,
            'enable' => $this->enable,
            'memo' => $this->memo,
            'expired_at' => $this->expired_at?->toDateTimeString(),
            'created_at' => $this->created_at?->toDateTimeString(),
            'updated_at' => $this->updated_at?->toDateTimeString(),
        ];
    }
} 